unit GirisiOlmayanUrun;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, FormClass, StdCtrls, Buttons, Wwdbigrd, Grids, Wwdbgrid,
  ExtCtrls, XPMan, StdActns, ActnList, DB;

type
  TfmGirisiOlmayanUrun = class(TfmFormClass)
    Panel1: TPanel;
    btOk: TBitBtn;
    btCancel: TBitBtn;
    Panel2: TPanel;
    grdList: TwwDBGrid;
    wwDBGrid2IButton: TwwIButton;
    BtnBos: TButton;
    procedure grdListCalcCellColors(Sender: TObject; Field: TField;
      State: TGridDrawState; Highlight: Boolean; AFont: TFont;
      ABrush: TBrush);
    procedure grdListRowChanged(Sender: TObject);
    procedure grdListCellChanged(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure grdListKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmGirisiOlmayanUrun: TfmGirisiOlmayanUrun;

implementation
uses uretim, Boxes, data;
{$R *.dfm}

procedure TfmGirisiOlmayanUrun.grdListCalcCellColors(Sender: TObject;
  Field: TField; State: TGridDrawState; Highlight: Boolean; AFont: TFont;
  ABrush: TBrush);
begin
  inherited;
  if fmMontajYapma.emirlishar.recordcount > 0 then
  begin
    if fmMontajYapma.emirlishar.FieldByName('urunck').text[1] = 'C' then
    begin
      AFont.Color := clBlack;
      ABrush.Color := clBlack;
    end
    else
      if Highlight then
      begin
        abrush.color := clNavy;
        afont.Color := clwhite;
        afont.Style := [fsBold];
      end
      else
      begin
        if fmMontajYapma.emirlishar.FieldByName('miktar').value = fmMontajYapma.emirlishar.FieldByName('yapilan').value then
        begin
          AFont.Color := clblack;
          ABrush.Color := $00A6C8F0;
        end
        else
        begin
          AFont.Color := clblack;
          ABrush.Color := clwhite;
        end;
      end;
  end;
end;

procedure TfmGirisiOlmayanUrun.grdListRowChanged(Sender: TObject);
begin
  inherited;
  if (btOk.Enabled) <> (fmMontajYapma.emirlishar.RecNo <> 1) then
  begin
    btOk.Enabled := fmMontajYapma.emirlishar.RecNo <> 1;
    BtnBos.SetFocus;
  end;
  BtnBos.SetFocus;
end;

procedure TfmGirisiOlmayanUrun.grdListCellChanged(Sender: TObject);
begin
  inherited;
  if (btOk.Enabled) <> (fmMontajYapma.emirlishar.RecNo <> 1) then
  begin
    btOk.Enabled := fmMontajYapma.emirlishar.RecNo <> 1;
    BtnBos.SetFocus;
  end;
  BtnBos.SetFocus;
end;

procedure TfmGirisiOlmayanUrun.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
//  inherited;
//  if (Key = VK_RETURN) and (ActiveControl.Name = 'grdList') then
    BtnBos.SetFocus;
end;

procedure TfmGirisiOlmayanUrun.grdListKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
//  if (Key = VK_RETURN) then
    BtnBos.SetFocus;
end;

end.

